// poke_dlg_window_op.cpp : implementation file
//

#include "stdafx.h"
#include "poke.h"
#include "ui/poke_dlg_window_op.h"
#include "models/atom_interface/ai_config.h"
#include "poke_framework.h"

// CPokeDlgWindowOp dialog

IMPLEMENT_DYNAMIC(CPokeDlgWindowOp, CDialog)

CPokeDlgWindowOp::CPokeDlgWindowOp(CWnd* pParent /*=NULL*/)
    : CDialog(CPokeDlgWindowOp::IDD, pParent)
{

}

CPokeDlgWindowOp::~CPokeDlgWindowOp()
{
}

void CPokeDlgWindowOp::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CPokeDlgWindowOp, CDialog)
    ON_BN_CLICKED(IDC_BUTTON_SHOWWINDOW_NA, &CPokeDlgWindowOp::OnBnClickedButtonShowwindowNa)
    ON_BN_CLICKED(IDC_BUTTON_HIDEWINDOW_NA, &CPokeDlgWindowOp::OnBnClickedButtonHidewindowNa)
    ON_BN_CLICKED(IDC_BUTTON_SHOWWINDOW, &CPokeDlgWindowOp::OnBnClickedButtonShowwindow)
    ON_BN_CLICKED(IDC_BUTTON_HIDEWINDOW, &CPokeDlgWindowOp::OnBnClickedButtonHidewindow)
    ON_BN_CLICKED(IDC_BUTTON_TOP, &CPokeDlgWindowOp::OnBnClickedButtonTop)
    ON_BN_CLICKED(IDC_BUTTON_BOTTOM, &CPokeDlgWindowOp::OnBnClickedButtonBottom)
    ON_BN_CLICKED(IDC_BUTTON_TOPMOST, &CPokeDlgWindowOp::OnBnClickedButtonTopmost)
    ON_BN_CLICKED(IDC_BUTTON_SETFOCUS, &CPokeDlgWindowOp::OnBnClickedButtonSetfocus)
    ON_BN_CLICKED(IDC_BUTTON_MAXMIZE, &CPokeDlgWindowOp::OnBnClickedButtonMaxmize)
    ON_BN_CLICKED(IDC_BUTTON_MAXMIZE_SYSCMD, &CPokeDlgWindowOp::OnBnClickedButtonMaxmizeSyscmd)
    ON_BN_CLICKED(IDC_BUTTON_MINIMIZE, &CPokeDlgWindowOp::OnBnClickedButtonMinimize)
    ON_BN_CLICKED(IDC_BUTTON_MINIMIZE_SYSCMD, &CPokeDlgWindowOp::OnBnClickedButtonMinimizeSyscmd)
    ON_BN_CLICKED(IDC_BUTTON_RESTORE, &CPokeDlgWindowOp::OnBnClickedButtonRestore)
    ON_BN_CLICKED(IDC_BUTTON_RESTORE_SYSCMD, &CPokeDlgWindowOp::OnBnClickedButtonRestoreSyscmd)
END_MESSAGE_MAP()


// CPokeDlgWindowOp message handlers

void CPokeDlgWindowOp::OnBnClickedButtonShowwindowNa()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::SetWindowPos(oConfig.hWindow, NULL, 0, 0, 0, 0,
        SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_ASYNCWINDOWPOS);
}

void CPokeDlgWindowOp::OnBnClickedButtonHidewindowNa()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::SetWindowPos(oConfig.hWindow, NULL, 0, 0, 0, 0,
        SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_ASYNCWINDOWPOS);
}

void CPokeDlgWindowOp::OnBnClickedButtonShowwindow()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::ShowWindow(oConfig.hWindow, SW_SHOW);
}

void CPokeDlgWindowOp::OnBnClickedButtonHidewindow()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::ShowWindow(oConfig.hWindow, SW_HIDE);
}

void CPokeDlgWindowOp::OnBnClickedButtonTop()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::SetWindowPos(oConfig.hWindow, HWND_TOP, 0, 0, 0, 0,
        SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS);
}

void CPokeDlgWindowOp::OnBnClickedButtonBottom()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::SetWindowPos(oConfig.hWindow, HWND_BOTTOM, 0, 0, 0, 0,
        SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS);
}

void CPokeDlgWindowOp::OnBnClickedButtonTopmost()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::SetWindowPos(oConfig.hWindow, HWND_TOPMOST, 0, 0, 0, 0,
        SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS);
}

void CPokeDlgWindowOp::OnBnClickedButtonSetfocus()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    // (TODO:) Attach thread input and set focus
}

void CPokeDlgWindowOp::OnBnClickedButtonMaxmize()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::ShowWindow(oConfig.hWindow, SW_SHOWMAXIMIZED);
}

void CPokeDlgWindowOp::OnBnClickedButtonMaxmizeSyscmd()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::PostMessage(oConfig.hWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}

void CPokeDlgWindowOp::OnBnClickedButtonMinimize()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::ShowWindow(oConfig.hWindow, SW_MINIMIZE);
}

void CPokeDlgWindowOp::OnBnClickedButtonMinimizeSyscmd()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::PostMessage(oConfig.hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
}

void CPokeDlgWindowOp::OnBnClickedButtonRestore()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::ShowWindow(oConfig.hWindow, SW_SHOWNORMAL);
}

void CPokeDlgWindowOp::OnBnClickedButtonRestoreSyscmd()
{
    // TODO: Add your control notification handler code here
    PokeConfig oConfig = {0};
    PokeFramework::get()->Execute(PAN_CONFIG, PFI_GET_CONFIG, &oConfig, NULL);
    if(NULL == oConfig.hWindow || !IsWindow(oConfig.hWindow)) {
        return;
    }

    ::PostMessage(oConfig.hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
}
